package com.chilli.cosima.action.customermanager;

import java.util.List;
import java.util.Map;

import com.chilli.cosima.action.BaseSupport;
import com.chilli.cosima.data.bean.Customer;
import com.chilli.cosima.service.CustomerService;

public class CustomerQueryQueryAction extends BaseSupport
{

	private static final long serialVersionUID = 361606870391234756L;
	private Long id;
	private Customer customer;
	private CustomerService customerService;
	private String input;

	public CustomerService getCustomerService()
	{
		return customerService;
	}

	public void setCustomerService(CustomerService customerService)
	{
		this.customerService = customerService;
	}

	public Long getId()
	{
		return id;
	}

	public void setId(Long id)
	{
		this.id = id;
	}

	public Customer getCustomer()
	{
		return customer;
	}

	public void setCustomer(Customer customer)
	{
		this.customer = customer;
	}

	public String getInput()
	{
		return input;
	}

	public void setInput(String input)
	{
		this.input = input;
	}

	@SuppressWarnings("unchecked")
	public String execute()
	{
		String page = request.getParameter("page");
		int current = 0;
		if (page != null && !"".equals(page))
		{
			current = Integer.parseInt(page);
		}

		Map map = customerService.findCustomerByPageAndQUery(current, pageSize, this.input);
		List list = (List) map.get("list");
		int count = (Integer) map.get("count");

		setPager(list, "customer/customerQueryQueryAction.action", count);
		return SUCCESS;
	}
}
